package class202205.demo25.demo23;



//写一个泛型类  求数组中最大值

import java.util.Arrays;

class Val<T extends Comparable<T>> {
    public T Max(T[] array) {
        T tmp = array[0];
        for (int i = 0; i < array.length; i++) {
            //if (tmp<array[i]){
            if (tmp.compareTo(array[i])<0){

                tmp = array[i];
            }
        }
        return tmp;
    }
}

public class demo20220523 {

    public static void main(String[] args) {
        Integer[] array = {52,6,7,23,41,13,19};
        Val<Integer> val = new Val<>();
        System.out.println(val.Max(array));

    }
}
